import axios from '@/libs/api.request'
import apiurl from './apiurl'

const getProducts = (params = { page, pageSize, keyword }) => {
  return axios.request({
    url: apiurl.getProducts,
    method: 'get',
    params
  })
}

const updateProduct = (data = { id, page, pageSize, keyword }) => {
  return axios.request({
    url: apiurl.updateProduct,
    method: 'post',
    data
  })
}

const deleteProduct = id => {
  return axios.request({
    url: apiurl.deleteProduct + `/${id}`,
    method: 'get'
  })
}

const getProduct = id => {
  return axios.request({
    url: apiurl.getProduct + `/${id}`,
    method: 'get'
  })
}

export default {
  getProducts,
  updateProduct,
  deleteProduct,
  getProduct
}
